/**
 * @param {number} k
 * @param {number} n
 * @return {number[][]}
 */

var combinationSum3 = function (k, n) {
    // 结果数组
    let res = []
    // 运营数组
    let arr = []
    backtracking(1)
    return res
    function backtracking(index) {
        if (arr.length === k && arr.reduce((pre, cur) => pre + cur) === n) {
            res.push(arr.slice())
            return 
        }
        for (let i = index; i <= 9; i++) {
            arr.push(i)
            backtracking(i + 1)
            arr.pop()
        }
    }
};